#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int main() {
    int year = 0;
    int month = 0;
    int day = 0;
    scanf("%d %d %d", &year, &month, &day);
    int sum[] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
    if (year % 4 == 0 && year % 100 != 0 || year % 400 == 0)
        sum[1] += 1;
    int sum_day = 0;
    for (int i = 0; i < month - 1; i++)
    {
        sum_day += sum[i];
    }
    printf("%d", sum_day + day);
    return 0;
}








